<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手动实现MVVM</title>
</head>

<body>
    <div id="root">
        <div>
            <span v-bind:id="id" v-on:click="click">{{data.num}}</span>
            <div v-bind:html="data.html"></div>
            <input type="text" v-model="username" />
            <input type="checkbox" v-model="isRemember" />记住密码
            <select v-model="sex">
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
            <div>
                <span>{{allName}}</span>
            </div>
        </div>
    </div>
    <script type="module">
        import MVVM from './mvvm.js';

        let mvvm = new MVVM({
            el: '#root',
            data: {
                id: 100,
                data: {
                    num: 10000,
                    html: '<div>html</div>'
                },
                username: '1812A',
                isRemember: false,
                sex: '女'
            },
            methods: {
                click: function () {
                    alert('click event');
                }
            },
            computed: {
                allName() {
                    return this.username + ' sir';
                }
            }
        })
        window.mvvm = mvvm;

    </script>
</body>

</html>